﻿<cfsilent>
	<cfscript>
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		stringAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");

		event.setArg("pageTitle", "信息查看");
		
		userId = sessionAdvice.getAutherUserID();
		
		id = event.getArg("id");
		
		sql = "SELECT t_message.*, t_user.user_name, a.user_name name FROM t_message 
				INNER JOIN t_user ON t_user.user_id = t_message.user_id
				INNER JOIN t_user a ON a.user_id = t_message.target_id 
				 where (target_id = :userId OR t_message.user_id = :userId) AND id = :id ";
		
		queryObj = new Query( datasource=application.dnsSlave);
		
		queryObj.addParam( name="userId", value=userId, cfsqltype="cf_sql_varchar" );
		queryObj.addParam( name="id", value=id, cfsqltype="cf_sql_integer" );
		
		rs_message = queryObj.execute( sql=sql ).getResult();
		
		
		sql = "UPDATE t_message SET target_state = '1' where target_id = :userId AND id = :id ";
		
		queryObj = new Query( datasource=application.dnsMaster);
		
		queryObj.addParam( name="userId", value=userId, cfsqltype="cf_sql_varchar" );
		queryObj.addParam( name="id", value=id, cfsqltype="cf_sql_integer" );
		
		queryObj.execute( sql=sql );
		
		sql = "UPDATE t_message SET user_state = '1' where user_id = :userId AND id = :id ";
		
		queryObj = new Query( datasource=application.dnsMaster);
		
		queryObj.addParam( name="userId", value=userId, cfsqltype="cf_sql_varchar" );
		queryObj.addParam( name="id", value=id, cfsqltype="cf_sql_integer" );
		
		queryObj.execute( sql=sql );
		
		
		/* 判断当前显示课表内容 */
		currentTab = event.getArg("TabID", "labSuggest");
		
	</cfscript>
</cfsilent>

<link rel="stylesheet" href="../kindediter/themes/default/default.css" />
<script charset="utf-8" src="../kindediter/kindeditor-min.js"></script>
<script charset="utf-8" src="../kindediter/lang/zh_CN.js"></script>

<script>
			var editor;
			KindEditor.ready(function(K) {
				editor = K.create('textarea[name="REPLY"]', {
					uploadJson : '../kindediter/jsp/upload_json.jsp',

					fileManagerJson : '../kindediter/jsp/file_manager_json.jsp',
					
					resizeType : 1,
					allowPreviewEmoticons : true,
					allowImageUpload : true,
					items : [
						'fontname', 'fontsize', '|', 'undo', 'redo', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
						'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
						'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
					 afterBlur: function(){this.sync();}
				});
			});
		</script>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="javascript:history.go(-1)"><i class="mrs img btnPublish"></i><span class="uiButtonText">返回</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>信息查看
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labSuggest">class="active"</cfif> id="labSuggest" tabTarget="Suggest">详情</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
			

				<div id="Suggest" class="tabContent">
					
					<cfif rs_message.recordCount>
                         
                         		<div class="noticeBlock">
								<h3><span class="img icon16x16 message"></span> 主题：<b><cfoutput>#rs_message.title#</cfoutput></b></h3>
								<p>
									
									用户： <cfoutput>#rs_message.user_name#</cfoutput>
									
								</p>
								<hr/>
							</div>
							
							
							<!--- 显示教学班评论信息--->
                                   
							<div class="mailContainer">
		
							<cfset row = 0 />
                                    
							<cfset row++ />
                                   
          
                                   <div class="mailBox">
                                        
                                        <div class="index"><i><cfoutput>#row#</cfoutput></i></div>
                                        
                                        <div class="box">
                                             
                                             
          
                                             <div class="main">
                                             
                                             	
                                                  <div class="header">
                                                     【<cfoutput>#rs_message.user_name#</cfoutput>】&nbsp;&nbsp;&nbsp;<b> 发送时间:</b> 
                                                       <span class="numeric"><cfoutput>#rs_message.user_time#</cfoutput></span>
                                                  </div>
                                                  <div class="message" style="width:650px;">
                                                       <b>◆</b>
                                                     	<div><cfoutput>#rs_message.user_content#</cfoutput></div>
                                                    
                                                  </div>
                                                  
                                                   <!---  <div class="operation <cfif (rs_message.re_content neq "") or (rs_message.user_id eq userId)>hidden_elem</cfif>">
											<cfif rs_message.isreplay eq "1" >
                                                            <a href="javascript:showReply('<cfoutput>#rs_message.id#</cfoutput>');">提交回复</a>
                                                       </cfif>
                                                  </div>--->
                                                
                                                  
                                                  <div class="reply <cfif rs_message.re_content eq "">hidden_elem</cfif>">
                                                       <span class="bot2"></span>
                                                       <span class="top2"></span>  
                                                       <!---<div><cfoutput>#stringAdvice.HTMLEncode( rs_message.re_content)#</cfoutput></div>--->
                                                       <div><cfoutput># rs_message.re_content#</cfoutput></div>
                                                  </div>
                                                  <div class="footer <cfif rs_message.re_content eq "">hidden_elem</cfif>">
                                                        【<cfoutput>#rs_message.name#</cfoutput>】&nbsp;&nbsp;&nbsp;<b>回复时间:</b> 
                                                       <span class="numeric"><cfoutput>#rs_message.re_time#</cfoutput></span>
                                                  </div>
                                                       
                                             </div>
          
                                        </div>
                                        
                                   </div>
          
                     
                               </div>
                               <div align="center">
                               <div align="center" style="width:673px" class="mailForm  <cfif (rs_message.re_content neq "") or (rs_message.isreplay neq "1" ) or (rs_message.user_id eq userId )>hidden_elem</cfif>">
                                   
                                    <form id="formReply" onSubmit="javascript:return processReply('formReply');" class="formWrapper" method="post" >
                                         
                                         <input type="hidden" id="msgId" name="msgId" value="<cfoutput>#id#</cfoutput>" />
                                     
                                         
                                         <textarea name="REPLY" id="REPLY" style="width:650px;height:200px;visibility:hidden;"></textarea>
                                         
                                         
                                         <hr/>
                
                                         <div class="lable">
                                              <input class="button" type="submit" value="提交回复" />
                                             <!--- <a class="button2" href="javascript:cancelReply('formReply');">取消</a>--->
                                         </div>
                                    
                                    </form>
                                    
                               </div></div>
                               
                               <script language="javascript" type="text/javascript">
                                    //<![CDATA[
                                    <!--
                                    function processReply( formId ) {
								
                
                                         var $form = $("form#" + formId);
                                         
                                         var msgId = $("#msgId").val();
                                         var reply = $("#REPLY").val();
								 
                                         var re = /.+/;
                
                                         if ( re.test(reply) ) {
                
                                              /* 异步提交回复数据 */
                                              $.post(
                                                        "<cfoutput>#buildURL('apiMessageReplySave')#</cfoutput>", 
                                                        {
                                                             "msgId": msgId, 
                                                             "REPLY": reply, 
                                                             "seed": (new Date()).getTime()
                                                        }, 
                                                        function(data){
                
                                                             //$("#out").html(data);
                                                             
                                                             var result = $.parseJSON(data);
                
                                                             if ( result.success ) {
													 
													 window.location.reload();
                
                                                                  var $reply = $("div.reply");
                                                                  var $foot = $("div.footer");
                                                                  
                                                                 // $("div", $reply).html( result.messageReply );
                                                                 // $reply.removeClass("hidden_elem");
                                                                  
                                                                 // $("span.numeric", $foot).html( result.messageDate );
                                                                 // $foot.removeClass("hidden_elem");
                
                                                                  /* 重置表单 */
                                                                  $("#msgId").val("");
                                                                  $("textarea", $form).val("").removeClass("typeError");
                                                                  
                                                                  /* 显示意见和建议 */
                                                                  $("div.mailForm").addClass("hidden_elem");
                
                                                             }
                                                             else {
                                                                  alert("无法保存回复");
                                                             }
                                                             
                                                        });
                                              
                                         }
                                         else {
                                              $("textarea", $form).addClass("typeError").focus();
                                         }
                                         
                                         return false;
                                    }
                                    
                                    function cancelReply( formId ) {
                                         
                                         var $form = $("form#" + formId);
                
                                         $("#MSG").val("");
                                         $("#HASH").val("");
                                         $("textarea", $form).val("").removeClass("typeError");
                                         
                                         $("div.mailForm").addClass("hidden_elem");
                                         $("div.operation").removeClass("hidden_elem");
                                         
                                    }
                                    
                                    function showReply( msgId ) {
								  $("div.operation").addClass("hidden_elem");
                                         
                                         var $message = $("div.mailBox[data-msg='" + msgId + "']");
                                         
                                         var suggest = $("div.message > div", $message).text();
                                         
                                         $("#msgId").val( msgId );
                                         
                                         $("#suggestContent").html( suggest );
                                         
                                        // $("div.mailContainer").addClass("hidden_elem");
                                         $("div.mailForm").removeClass("hidden_elem");
								 document.getElementById('REPLY').focus();
								 $("#REPLY").focus();
                                         
                                    }
                                    // -->
                                    //]]>
                               </script>
                               
						<cfelse>
							<div class="systemNotice">
								<p class="mln">非法访问！.</p>
							</div>
					</cfif>

				</div>
				
			</div>
		</li>
	</ul>
</div>

